﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Pluto.Wpf.Controls.Tab;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using Test.Views;

namespace Test.ViewModels
{
    public class MainWindowViewModel : ObservableObject
    {
        #region props
        /// <summary>
        /// 
        /// </summary>
        public ObservableCollection<Tab> Tabs { get; set; } = new ObservableCollection<Tab>();

        private Tab _SelectedTab;
        
        #endregion

        public RelayCommand AddTabCMD { set; get; }

        #region methods
        public MainWindowViewModel()
        {
            InitCommand();
        }

        private void InitCommand()
        {
            AddTabCMD = new RelayCommand(OnAddTabCMD);
        }

        private void OnAddTabCMD()
        {
            var list = new List<Page>
            {
                new Page1(),
                new Page2(),
            };

            Page item = list.First();
            Button testNameBtn = item.FindName("TestNameBtn") as Button;

            var random = new Random();

            Tabs.Add(new Tab
            {
                ContentPage = list[random.Next(0, 2)],
                Header = $"tab{Tabs.Count + 1}",
                TabWidth = 100
            });
        }

        #endregion
    }
}
